from scrapy.spider import BaseSpider
from scrapy.selector import HtmlXPathSelector
from tutorial.items import DmozItem



class DmozSpider(BaseSpider):
    name = "dmoz"
    #allowed_domains = ["dmoz.org"]
    allowed_domains = ["www.thereminvox.com"]
    start_urls = [
       "http://www.thereminvox.com/filemanager/list/1/index.html"
        #"http://www.dmoz.org/Computers/Programming/Languages/Python/Books/",
        #"http://www.dmoz.org/Computers/Programming/Languages/Python/Resources/"
    ]

    def parse(self, response):
        sel = HtmlXPathSelector(response)
        #sites = sel.xpath('//ul/li')
        sites = sel.xpath("//div[@class='topicPageTitle']/text()")


	items = []
        for site in sites:
           item = DmozItem()
           item['title'] = site.extract()
           #item['link'] = site.xpath('a/@href').extract()
           #item['desc'] = site.xpath('text()').extract()
           items.append(item)
	return items
